package com.solarroast.mirrorarray.gui;

import java.awt.GridLayout;
import java.util.ArrayList;

import javax.swing.BoxLayout;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.UIManager;

import com.solarroast.mirrorarray.components.Mirror;

public class MirrorArrayItemWindow extends JFrame {
	/**
	 * 
	 */
	private static final long serialVersionUID = -4516565426339402883L;
	private String title;
	private ArrayList<Mirror> mArray;
	private JPanel mAIPanel;
	
	public MirrorArrayItemWindow(String title) {
		this.title = "Status";
		
		try {
			UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
		}
		catch(Exception e) {
			e.printStackTrace();
		}
		
		initWindow();
	}
	
	private void initWindow() {
		setTitle(title);
		setLayout(new BoxLayout(this.getContentPane(), BoxLayout.PAGE_AXIS));
		setAlwaysOnTop(true);
		setSize(200,200);
		
		mAIPanel = new JPanel();
		mAIPanel.setLayout(new GridLayout(2, 2));
				
		add(mAIPanel);
	}
	
	public void setMirrorArray(ArrayList<Mirror> mArray) {
		this.mArray = mArray;
	}
	
	public void redraw() {
		//mirrorInfo.setText(text.toString());
		mAIPanel.removeAll();
		for(int i = 0; i < mArray.size(); i++) {
			mAIPanel.add(mArray.get(i).getButton());
		}
		
		pack();
		setTitle(title);
		setResizable(false);
		setAlwaysOnTop(true);
		setVisible(true);
	}
}
